package com.wind.easycode.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wind.easycode.dao.TestT10Dao;
import com.wind.easycode.entity.TestT10;
import com.wind.easycode.service.TestT10Service;
import org.springframework.stereotype.Service;
import com.wind.easycode.common.utils.PageUtils;
import com.wind.easycode.common.base.BaseModelPageDTO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wind.easycode.common.utils.Query;
import org.apache.commons.lang3.StringUtils;

/**
 * 应用表(TestT10)表服务实现类
 *
 * @author makejava
 * @since 2024-05-21 11:14:30
 */
@Service("testT10Service")
public class TestT10ServiceImpl extends ServiceImpl<TestT10Dao, TestT10> implements TestT10Service {

  @Autowired
  private  TestT10Dao testT10Dao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TestT10> page = this.page(
                new Query<TestT10>().getPage(params),
                new QueryWrapper<TestT10>()
        );
        return new PageUtils(page);
    }

  @Override
  public PageUtils queryPage(BaseModelPageDTO<TestT10> data) {
    TestT10 entity = data.getData();
    QueryWrapper<TestT10> queryWrapper = null;
    //分页查询所有
    if(entity==null){
      queryWrapper = new QueryWrapper<TestT10>();
    }else{
      queryWrapper = new QueryWrapper<TestT10>();
      queryWrapper = getTestT10QueryWrapper(entity, queryWrapper);
    }
    IPage<TestT10> page = this.page(
        new Query<TestT10>().getPage(data),
        queryWrapper
    );
    return new PageUtils(page);
  }

  @Override
  public PageUtils queryPage(TestT10 entity) {
    BaseModelPageDTO<TestT10> data=new BaseModelPageDTO<TestT10>();
    data.setData(entity);
    return queryPage(data);
  }

   @Override
    public List<TestT10> query(TestT10 data){
    TestT10 entity = data;
    QueryWrapper<TestT10> queryWrapper = null;
    //分页查询所有
    if(entity==null){
      queryWrapper = new QueryWrapper<TestT10>();
    }else{
      queryWrapper = new QueryWrapper<TestT10>();
      queryWrapper = getTestT10QueryWrapper(entity, queryWrapper);
    }
    return testT10Dao.selectList(queryWrapper);
}

   @Override
    public TestT10 getOne(TestT10 data){
    TestT10 entity = data;
    QueryWrapper<TestT10> queryWrapper = null;
    //分页查询所有
    if(entity==null){
      queryWrapper = new QueryWrapper<TestT10>();
    }else{
      queryWrapper = new QueryWrapper<TestT10>();
      queryWrapper = getTestT10QueryWrapper(entity, queryWrapper);
    }
    return super.getOne(queryWrapper);
}


  private QueryWrapper<TestT10> getTestT10QueryWrapper(TestT10 entity, QueryWrapper<TestT10> queryWrapper) {
  
   if(entity.getId()!=null){
      queryWrapper=queryWrapper.eq("id", entity.getId());
   }
   if(StringUtils.isNotEmpty(entity.getName())){
      queryWrapper=queryWrapper.eq("name", entity.getName());
   }
   if(StringUtils.isNotEmpty(entity.getAct())){
      queryWrapper=queryWrapper.eq("act", entity.getAct());
   }
   if(StringUtils.isNotEmpty(entity.getStory())){
      queryWrapper=queryWrapper.eq("story", entity.getStory());
   }
   if(StringUtils.isNotEmpty(entity.getSource())){
      queryWrapper=queryWrapper.eq("source", entity.getSource());
   }
   if(StringUtils.isNotEmpty(entity.getCharpter())){
      queryWrapper=queryWrapper.eq("charpter", entity.getCharpter());
   }
   if(StringUtils.isNotEmpty(entity.getCharpterUrl())){
      queryWrapper=queryWrapper.eq("charpter_url", entity.getCharpterUrl());
   }
   if(StringUtils.isNotEmpty(entity.getUrl())){
      queryWrapper=queryWrapper.eq("url", entity.getUrl());
   }
   if(StringUtils.isNotEmpty(entity.getParentUrl())){
      queryWrapper=queryWrapper.eq("parent_url", entity.getParentUrl());
   }
   if(StringUtils.isNotEmpty(entity.getCompany())){
      queryWrapper=queryWrapper.eq("company", entity.getCompany());
   }
   return queryWrapper;
}

}

